package paneles;

import java.awt.AWTEventMulticaster;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

import principal.ControladorPartida;
import principal.ControladorPartida;


public class PanelMini extends JPanel implements ActionListener {

	private static final int INIX=0;
	private static final int INIY=0;
	private static final int AREA = 40;
	private Font fNum = new Font(Font.MONOSPACED, Font.BOLD, 12);
	JButton uno = new JButton("1");
	JButton dos = new JButton("2");
	JButton tres = new JButton("3");
	JButton cuatro = new JButton("4");
	JButton cinco = new JButton("5");
	JButton seis = new JButton("6");
	JButton siete = new JButton("7");
	JButton ocho = new JButton("8");
	JButton nueve = new JButton("9");
	Insets mg = new Insets(1,1,1,1);
	public String seleccion;
	ControladorPartida motor;
	
	public PanelMini() {
		setOpaque(false);
		setSize(40,40);
		setName("panelMini");
		this.setLayout(new GridLayout(3,3));
		setPreferredSize(new Dimension(600,550));
		formato(uno);
		formato(dos);
		formato(tres);
		formato(cuatro);
		formato(cinco);
		formato(seis);
		formato(siete);
		formato(ocho);
		formato(nueve);

		setVisible(false);
	}
	
	
	private void formato(JButton b) {
		b.setFont(fNum);
		b.setMargin(mg);
		b.addActionListener(this);
		add(b);
	}

	public void addInstancia(ControladorPartida obj) {
		motor = obj;
	}
	
	
	//@Override
	public void actionPerformed(ActionEvent arg) {
		Integer i = new Integer(arg.getActionCommand());
//		JOptionPane.showMessageDialog(null, "mini-actionPerformer "+i.intValue());
//		motor.entraNumero(i.intValue());
		//TODO resolver la adjudicacion del numero a la celda
//		motor.entraPosible(i.intValue());
		this.setVisible(false);
//		ActionEvent av = new ActionEvent(this,1,st);
//	    receptorAction.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, st));
//	      }
//		new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "mini",5);
	}
	
}
